home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d13 / ptv2n1.arc / GENERIC.PAS < prev    next >
Pascal/Delphi Source File  |  1991-03-26  |  2KB  |  109 lines

  1. {************************************************}
  2. {   Turbo Pascal for Windows                     }
  3. {   Demo program                                 }
  4. {   Copyright (c) 1991 by Borland International  }
  5. {************************************************}
  6. { "Generic" Windows application written in Turbo Pascal }
  7.  
  8. program Generic;
  9.  
  10. {$R GENERIC}
  11.  
  12. uses WinTypes, WinProcs;
  13.  
  14. const
  15.   AppName = 'Generic';
  16.   idm_About = 100;
  17.  
  18. function About(Dialog: HWnd; Message, WParam: Word;
  19.                LParam: Longint): Bool; export;
  20. begin
  21.   About := True;
  22.   case Message of
  23.     wm_InitDialog:
  24.       Exit;
  25.     wm_Command:
  26.       if (WParam = id_Ok) or (WParam = id_Cancel) then
  27.       begin
  28.         EndDialog(Dialog, 1);
  29.         Exit;
  30.       end;
  31.   end;
  32.   About := False;
  33. end;
  34.  
  35. function WindowProc(Window: HWnd; Message, WParam: Word;
  36.                     LParam: Longint): Longint; export;
  37. var
  38.   AboutProc: TFarProc;
  39. begin
  40.   WindowProc := 0;
  41.   case Message of
  42.     wm_Command:
  43.       if WParam = idm_About then
  44.       begin
  45.         AboutProc := MakeProcInstance(@About, HInstance);
  46.         DialogBox(HInstance, 'AboutBox', Window, AboutProc);
  47.         FreeProcInstance(AboutProc);
  48.         Exit;
  49.       end;
  50.     wm_Destroy:
  51.       begin
  52.         PostQuitMessage(0);
  53.         Exit;
  54.       end;
  55.   end;
  56.   WindowProc := DefWindowProc(Window, Message, WParam, LParam);
  57. end;
  58.  
  59. procedure WinMain;
  60. var
  61.   Window: HWnd;
  62.   Message: TMsg;
  63. const
  64.   WindowClass: TWndClass = (
  65.     style: 0;
  66.     lpfnWndProc: @WindowProc;
  67.     cbClsExtra: 0;
  68.     cbWndExtra: 0;
  69.     hInstance: 0;
  70.     hIcon: 0;
  71.     hCursor: 0;
  72.     hbrBackground: 0;
  73.     lpszMenuName: AppName;
  74.     lpszClassName: AppName);
  75. begin
  76.   if HPrevInst = 0 then
  77.   begin
  78.     WindowClass.hInstance := HInstance;
  79.     WindowClass.hIcon := LoadIcon(0, idi_Application);
  80.     WindowClass.hCursor := LoadCursor(0, idc_Arrow);
  81.     WindowClass.hbrBackground := GetStockObject(white_Brush);
  82.     if not RegisterClass(WindowClass) then Halt(255);
  83.   end;
  84.   Window := CreateWindow(
  85.     AppName,
  86.     'Turbo Pascal Generic',
  87.     ws_OverlappedWindow,
  88.     cw_UseDefault,
  89.     cw_UseDefault,
  90.     cw_UseDefault,
  91.     cw_UseDefault,
  92.     0,
  93.     0,
  94.     HInstance,
  95.     nil);
  96.   ShowWindow(Window, CmdShow);
  97.   UpdateWindow(Window);
  98.   while GetMessage(Message, 0, 0, 0) do
  99.   begin
  100.     TranslateMessage(Message);
  101.     DispatchMessage(Message);
  102.   end;
  103.   Halt(Message.wParam);
  104. end;
  105.  
  106. begin
  107.   WinMain;
  108. end.
  109.